#商品列表
def shop():
    print("#######商品列表###########")
    print("1、苹果  1.2元/斤")
    print("2、香蕉  5.5元/斤")
    print("#########################")


#购物选择
def shopping(money):
    choose1 = input("请输入你要购买的商品编号：")
    choose2 = float(input("请输入你要购买的数量："))
    sum = 0
    if choose1 == '1':
        sum = 1.2 * choose2
    elif choose1 == '2':
        sum = 5.5 * choose2
    else:
        print("输入错误！")

    if sum <= money:
        money = money - sum
        print(f"购买成功，您的剩余余额为{money}")
        if choose1 == '1':
            bought.append(f"苹果 {choose2}斤")
        else:
            bought.append(f"香蕉  {choose2}斤")

    else:
        print("你的预算已经超额！")
    return money



#登入
print("欢迎登入三乐购物系统！")
lst = [('user1','123456'),('user2','abcdefg')]
user = input("请输入用户名：")
passwd = input("请输入密码：")
if (user,passwd) in lst:
    print("登入成功!")
else:
    print("登入失败！")
    quit()
money = int(input("请输入您的购物预算："))
bought = []
while True:
    choose = input("输入1可查看商品列表\n输入2可查看已购买信息\n输入3可查看余额\n输入4可购买商品\n输入exit可退出\n请输入您的选择：")
    if choose == '1':
        shop()
    elif choose == '2':
        print("####购买清单#####")
        print(bought)
    elif choose == '3':
        print(money)
    elif choose == '4':
        money = shopping(money)
    elif choose == 'exit':
        print("####购买清单#####")
        print(bought)
        print(f"剩余余额:{money}")
        quit()
    else:
        print("输入错误请重新输入！")